package com.mf.cloud.controller;

import cn.hutool.core.util.IdUtil;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.TimeUnit;

/**
 * @Author: lmf
 * @Create: 2024/3/17 16:18
 * Description:  测试隔离
 */
@RestController
@Tag(name="测试服务隔离(限制并发)")
public class PayBulkheadController {

    @GetMapping("/pay/bulkhead/{id}")
    @Operation(summary = "测试接口")
    public String myBulkhead(@PathVariable("id") Integer id){
        if (id == -4) throw new RuntimeException("不能为负数");
        if (id == 9999) {

            try {
                TimeUnit.SECONDS.sleep(5);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

        }
        return "hello,bulkhead! inputID" + id + "\t " + IdUtil.simpleUUID();
    }
}
